package interview.java.zhangdong.designpattern.observer;

import java.util.ArrayList;

public class Subject {
	private ArrayList<Observer> observers = new ArrayList<Observer>();
	
	public void addObserver(Observer observer){
		if(!observers.contains(observer)){
			observers.add(observer);
		}
	}
	
	public void removeObserver(Observer observer){
		observers.remove(observer);
	}
	
	public void notifyAllObservers(){
		for(Observer ob : observers){
			ob.update();
		}
	}
}
